﻿using RRQMCore.ByteManager;
using RRQMSocket;
using Server.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Server
{
    public class MySocketClient : SocketClient
    {
        protected override void HandleReceivedData(ByteBlock byteBlock, object obj)
        {

			string mes = Encoding.UTF8.GetString(byteBlock.Buffer, 0, (int)byteBlock.Len);
			Debug.Log(mes);
           string[] list= JsonHelper.ClientRequest_deserialization(mes);
            string uid = list[0];
            string otype = list[1];
            string operate = list[2];
            string text = list[3];
			switch (otype)
			{
                case "sc":
					switch (operate)
					{
						case "mu":
							 
							returnValue("sc","mu",SearchFull.searchMusic(text));
							break;
						case "gro":
							SearchFull.searchGroup(text);
							break;
						default:
							break;
					}
					break;
				default:
					break;
			}

		}
		void returnValue(string tab, string ret)

		{

			string sid = "server";

			var json = JsonHelper.ServerRequest_serialization(sid, tab, ret);
			this.Send(Encoding.UTF8.GetBytes(json));
		}

		 void returnValue(string sid, string tab, string ret)
		{
			var json = JsonHelper.ServerRequest_serialization(sid, tab, ret);
			this.Send(Encoding.UTF8.GetBytes(json));
		}
		 void returnValue( string _uid, string sid, string tab, string ret)
		{
			var json = JsonHelper.ServerRequest_serialization(sid, tab, ret);
			this.Send(Encoding.UTF8.GetBytes(json));
		}
		 void returnValue( string sid, string tab, string ret, string[] arr)
		{
			var json = JsonHelper.ServerRequest_serialization(sid, tab, ret, arr);
			this.Send(Encoding.UTF8.GetBytes(json));
		}
		 void returnValue( string tab, string ret, string[] arr)
		{
			string sid = "server";

			var json = JsonHelper.ServerRequest_serialization(sid, tab, ret, arr);
			this.Send( Encoding.UTF8.GetBytes(json));
		}

	}
}
